package panels;

import islemler.KullaniciYonet;

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JComponent;

import javax.swing.AbstractButton;
import javax.swing.JOptionPane;
import javax.swing.WindowConstants;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.LayoutStyle;

import panels.KullaniciEklePanel.EklemeIslemi;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class KullaniciSilPaneli extends javax.swing.JPanel {
	private JTextField silFeild;
	private JPasswordField sifreField;
	private JButton silButonu;
	private JLabel sifreLabel;
	private JLabel kullaniciAdiLabel;

	/**
	* Auto-generated main method to display this 
	* JPanel inside a new JFrame.
	*/
	public static void main(String[] args) {
		JFrame frame = new JFrame();
		frame.getContentPane().add(new KullaniciSilPaneli());
		frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		frame.pack();
		frame.setVisible(true);
	}
	
	public KullaniciSilPaneli() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			GroupLayout thisLayout = new GroupLayout((JComponent)this);
			this.setLayout(thisLayout);
			setPreferredSize(new Dimension(400, 300));
			{
				silFeild = new JTextField();
			}
			{
				kullaniciAdiLabel = new JLabel();
				kullaniciAdiLabel.setText("Kullanici adi :");
			}
			{
				sifreField = new JPasswordField();
			}
			{
				sifreLabel = new JLabel();
				sifreLabel.setText("Sifre :");
			}
			{
				silButonu = new JButton();
				silButonu.setText("S\u0130L");
				silButonu.addActionListener(new SilmeIslemi());
			}
				thisLayout.setVerticalGroup(thisLayout.createSequentialGroup()
					.addContainerGap(59, 59)
					.addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
					    .addComponent(silFeild, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					    .addComponent(kullaniciAdiLabel, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
					.addGap(49)
					.addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
					    .addComponent(sifreField, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					    .addComponent(sifreLabel, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
					.addGap(37)
					.addComponent(silButonu, GroupLayout.PREFERRED_SIZE, 27, GroupLayout.PREFERRED_SIZE)
					.addContainerGap(86, Short.MAX_VALUE));
				thisLayout.setHorizontalGroup(thisLayout.createSequentialGroup()
					.addContainerGap(46, 46)
					.addGroup(thisLayout.createParallelGroup()
					    .addComponent(kullaniciAdiLabel, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 103, GroupLayout.PREFERRED_SIZE)
					    .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
					        .addComponent(sifreLabel, GroupLayout.PREFERRED_SIZE, 59, GroupLayout.PREFERRED_SIZE)
					        .addGap(44))
					    .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
					        .addGap(48)
					        .addComponent(silButonu, GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE)))
					.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
					.addGroup(thisLayout.createParallelGroup()
					    .addGroup(thisLayout.createSequentialGroup()
					        .addComponent(silFeild, GroupLayout.PREFERRED_SIZE, 127, GroupLayout.PREFERRED_SIZE))
					    .addGroup(thisLayout.createSequentialGroup()
					        .addComponent(sifreField, GroupLayout.PREFERRED_SIZE, 127, GroupLayout.PREFERRED_SIZE)))
					.addContainerGap(106, Short.MAX_VALUE));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public void kullIslemPanel() {
		this.removeAll();
		KullaniciIslemPanel islemPanel = new KullaniciIslemPanel();
		islemPanel.setSize(600, 300);
		add(islemPanel);
		this.revalidate();
		this.repaint();
		islemPanel.revalidate();
		islemPanel.repaint();
	}
	
public class SilmeIslemi implements ActionListener{
		
		@Override
		public void actionPerformed(ActionEvent e) {
			KullaniciYonet kullYonet = new KullaniciYonet();
			kullYonet.sil(silFeild.getText(), new String(sifreField.getPassword()));
			if (kullYonet.getBasariKodu()==0){
				JOptionPane .showMessageDialog(null, "basari ile silindi.");
			    kullIslemPanel();
			}
			else 
				JOptionPane.showMessageDialog(null, "silinemedi.");
   }
	
}
}